//
//  ODContactTableViewData.swift
//  OdmIM
//
//  Created by Gao on 17/1/18.
//  Copyright © 2017年 OdmIM. All rights reserved.
//

import UIKit

struct ContactItem {
    var phoneNumberStr:String = ""
    var nameStr:String = ""
}

struct ContactSectionItem {
    var indexTitleStr:String = ""
    var contactItemList:[ContactItem] = [ContactItem]()
}

class ODContactTableViewData: UIViewController /*, UITableViewDataSource, UITableViewDelegate*/ {
    
    let contactIndexTitleList:[String] = [
        "A", "B", "C", "D", "E", "F", "G",
        "H", "I", "J", "K", "L", "M", "N",
        "O", "P", "Q", "R", "S", "T",
        "U", "V", "W", "X", "Y", "Z"]
    
 
    var contactSectionItemList:[ContactSectionItem] = [ContactSectionItem]()
    
    
    func generateContactSectionList(){
        //reset
        contactSectionItemList = [ContactSectionItem]()
        
        for eachIndexTitle in contactIndexTitleList {
            var currentContactSectionItem = ContactSectionItem()
            var singleContactItem:ContactItem
            

            
            
            switch eachIndexTitle {
            case "C":
                currentContactSectionItem.indexTitleStr = eachIndexTitle
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "ch"
                singleContactItem.phoneNumberStr = "11112222333"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                contactSectionItemList.append(currentContactSectionItem)
            case "L":
                currentContactSectionItem.indexTitleStr = eachIndexTitle
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "lm"
                singleContactItem.phoneNumberStr = "11112222333"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "ljl"
                singleContactItem.phoneNumberStr = "11112222333"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                contactSectionItemList.append(currentContactSectionItem)
            case "M":
                currentContactSectionItem.indexTitleStr = eachIndexTitle
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "mjp"
                singleContactItem.phoneNumberStr = "11112222333"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "mz"
                singleContactItem.phoneNumberStr = "11112222333"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                contactSectionItemList.append(currentContactSectionItem)
            case "W":
                currentContactSectionItem.indexTitleStr = eachIndexTitle
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "wt"
                singleContactItem.phoneNumberStr = "11122233344"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                contactSectionItemList.append(currentContactSectionItem)
            case "X":
                currentContactSectionItem.indexTitleStr = eachIndexTitle
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "xc"
                singleContactItem.phoneNumberStr = "11112222333"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "xjm"
                singleContactItem.phoneNumberStr = "11112222333"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                contactSectionItemList.append(currentContactSectionItem)
            case "Z":
                currentContactSectionItem.indexTitleStr = eachIndexTitle
                
                singleContactItem = ContactItem()
                singleContactItem.nameStr = "zbl"
                singleContactItem.phoneNumberStr = "11112222333"
                currentContactSectionItem.contactItemList.append(singleContactItem)
                contactSectionItemList.append(currentContactSectionItem)
                
            default:
                break
            }
        }
    }
    
    func updateContactData(){
        generateContactSectionList()
    }
    
}

